using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using Avalonia.VisualTree;
using System;

namespace IntegratedMeasuring.Utils;

/// <summary>
/// 通知帮助类 - 使用Semi.Avalonia的Notification组件
/// </summary>
public static class NotificationHelper
{
    private static WindowNotificationManager? _manager;

    /// <summary>
    /// 初始化通知管理器
    /// </summary>
    /// <param name="control">当前控件</param>
    public static void Initialize(Control control)
    {
        var topLevel = TopLevel.GetTopLevel(control);
        if (topLevel != null)
        {
            _manager = new WindowNotificationManager(topLevel) 
            { 
                MaxItems = 3,
                Position = NotificationPosition.TopRight
            };
        }
    }

    /// <summary>
    /// 显示信息通知
    /// </summary>
    /// <param name="title">标题</param>
    /// <param name="message">消息内容</param>
    public static void ShowInfo(string title, string message)
    {
        _manager?.Show(new Notification(title, message, NotificationType.Information));
    }

    /// <summary>
    /// 显示成功通知
    /// </summary>
    /// <param name="title">标题</param>
    /// <param name="message">消息内容</param>
    public static void ShowSuccess(string title, string message)
    {
        _manager?.Show(new Notification(title, message, NotificationType.Success));
    }

    /// <summary>
    /// 显示警告通知
    /// </summary>
    /// <param name="title">标题</param>
    /// <param name="message">消息内容</param>
    public static void ShowWarning(string title, string message)
    {
        _manager?.Show(new Notification(title, message, NotificationType.Warning));
    }

    /// <summary>
    /// 显示错误通知
    /// </summary>
    /// <param name="title">标题</param>
    /// <param name="message">消息内容</param>
    public static void ShowError(string title, string message)
    {
        _manager?.Show(new Notification(title, message, NotificationType.Error));
    }

    /// <summary>
    /// 显示轻量级信息通知
    /// </summary>
    /// <param name="title">标题</param>
    /// <param name="message">消息内容</param>
    public static void ShowLightInfo(string title, string message)
    {
        _manager?.Show(
            new Notification(title, message),
            type: NotificationType.Information,
            classes: ["Light"]);
    }

    /// <summary>
    /// 显示轻量级成功通知
    /// </summary>
    /// <param name="title">标题</param>
    /// <param name="message">消息内容</param>
    public static void ShowLightSuccess(string title, string message)
    {
        _manager?.Show(
            new Notification(title, message),
            type: NotificationType.Success,
            classes: ["Light"]);
    }

    /// <summary>
    /// 显示轻量级警告通知
    /// </summary>
    /// <param name="title">标题</param>
    /// <param name="message">消息内容</param>
    public static void ShowLightWarning(string title, string message)
    {
        _manager?.Show(
            new Notification(title, message),
            type: NotificationType.Warning,
            classes: ["Light"]);
    }

    /// <summary>
    /// 显示轻量级错误通知
    /// </summary>
    /// <param name="title">标题</param>
    /// <param name="message">消息内容</param>
    public static void ShowLightError(string title, string message)
    {
        _manager?.Show(
            new Notification(title, message),
            type: NotificationType.Error,
            classes: ["Light"]);
    }
} 